cmake_minimum_required(VERSION 3.5.1)
project(segment_post_plugin)
set(CMAKE_CXX_STANDARD 11)

add_compile_options(-std=c++11 -O3 -Wall)

option(WITH_CROSS_COMPILE "cross compile" OFF)

if (WITH_CROSS_COMPILE)
    message("not compile segment plugin")
else()
    set(CMAKE_CXX_COMPILER "g++")
    set(LIBRARY_OUTPUT_PATH ../../lib)
    include_directories(../../../cpp)

    find_package(PkgConfig REQUIRED)
    pkg_check_modules(OPENCV opencv)
    if(OPENCV_FOUND)
        include_directories(${OPENCV_INCLUDE_DIRS})
        link_directories(${OPENCV_LIBRARY_DIRS})
        link_libraries(${OPENCV_LIBRARIES})
        add_compile_options(${OPENCV_CFLAGS_OTHER})
        add_definitions(-DHAVE_OPENCV)
    else(OPENCV_FOUND)
        pkg_check_modules(OPENCV4 opencv4)
        if(OPENCV4_FOUND)
            include_directories(${OPENCV4_INCLUDE_DIRS})
            link_directories(${OPENCV4_LIBRARY_DIRS})
            link_libraries(${OPENCV4_LIBRARIES})
            add_compile_options(${OPENCV4_CFLAGS_OTHER})
            add_definitions(-DHAVE_OPENCV)
        else(OPENCV4_FOUND)
            MESSAGE("Don't have opencv, You can install opencv!")
        endif(OPENCV4_FOUND)
    endif(OPENCV_FOUND)

    include_directories(/usr/local/lynxi/include ../../../cpp)

    add_library(Yolov8SegmentPostPlugin SHARED yolov8s_segment_plugin.cpp)

endif()
